package jdbc;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;

/**
 * Created by kevin on 2020/3/24.
 */
public class JdbcUtils {
    private static Properties properties = null;
    static {
        try {
//            InputStream in = JdbcUtils.class.getClassLoader().getResourceAsStream("dbconfig.properties");
            properties = new Properties();
//            properties.load(in);
            properties.load(new FileInputStream("./src/main/resources/dbconfig.properties"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public static Connection getConnection() throws Exception{
        Class.forName(properties.getProperty("driverClassName"));
        return DriverManager.getConnection(properties.getProperty("url"),properties.getProperty("name"),properties.getProperty("password"));
    }


}
